package demo2;
import java.util.List;
public class TestList {
    public void addEmp(List<Emp>list,Emp emp){
        list.add(emp);
    }
    public void findAllEmp(List<Emp> list){
        for (int i=0; i<list.size();i++){
            System.out.println(list.get(i));
        }
    }
    public Emp findEmpName(List<Emp> list,String empName){
        for (int i=0; i<list.size();i++){
            if(empName.equals(list.get(i).getName())){
                return list.get(i);
            }
        }
        return null;
    }
    public void deleteEmp(List<Emp> list,String empNumber){
        for (int i=0; i<list.size();i++){
            if (empNumber.equals(list.get(i).getNumber())){
                list.remove(i);
            }
        }
    }
    public Emp EmpNumber(List<Emp> list,String empNumber){
        for (int i=0;i<list.size();i++){
            if (empNumber.equals(list.get(i).getNumber())){
                return list.get(i);
            }
        }
        return null;
    }

    public void changEmpAge(List<Emp> list, String empNumber,int empAge){
        for (int i=0;i<list.size();i++){
            if (empNumber.equals(list.get(i).getNumber())){
                list.get(i).setAge(empAge);
            }
        }
        System.out.println("未找到对应的员工编号");
    }
}
